package com.lidian.beanutiltest;

import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import org.apache.commons.beanutils.BeanUtils;

public class BeanUtilTest {

	public static void main(String[] args) {
		Month month = new Month(1, "Jan");

		try {
			Map map = BeanUtils.describe(month);
			Set keySet = map.keySet();
			for (Iterator iter = keySet.iterator(); iter.hasNext();) {
				Object element = (Object) iter.next();
				System.out.println("KeyClass:" + element.getClass().getName());
				System.out.println("ValueClass:"
						+ map.get(element).getClass().getName());
				System.out.print(element + "\t");
				System.out.print(map.get(element));
				System.out.println();
			}
		} catch (IllegalAccessException e1) {
			e1.printStackTrace();
		} catch (InvocationTargetException e2) {
			e2.printStackTrace();
		} catch (NoSuchMethodException e3) {
			e3.printStackTrace();
		}
	}

}
